package com.air.designmodel.six.strategy.handler;

import com.air.designmodel.six.common.CommonPairResponse;
import com.air.designmodel.six.common.FormSubmitRequest;
import com.air.designmodel.six.strategy.FormSubmitHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.io.Serializable;

/**
 * HSF远程rpc调用框架(类比dubbo)
 * HSF模式提交
 *
 * @author shent
 */
@Component
public class FormHsfSubmitHandler implements FormSubmitHandler<Serializable> {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Override
    public String getSubmitType() {
        return "hsf";
    }

    @Override
    public CommonPairResponse<String, Serializable> handleSubmit(FormSubmitRequest request) {
        logger.info("HSF模式提交:userId:{},formInput={}", request.getUserId(), request.getFormInput());
        // 进行 HSF 泛化调用，获得业务方返回的提示信息和业务数据
        return hsfSubmitData(request);
    }

    private CommonPairResponse<String, Serializable> hsfSubmitData(FormSubmitRequest request) {
        //业务
        return CommonPairResponse.success("HSF输入模式提交数据成功!", null);
    }
}
